<template>
  <div class="employee-registration-page">
    <!-- 右上角返回按钮 -->
    <el-button type="text" class="return-btn" @click="handleReturn">返回</el-button>

    <!-- 标签切换区（修正样式，保持表格和其他部分不变） -->
    <div class="tab-container">
      <el-button
        :class="activeTab === 'agent' ? 'tab-btn active' : 'tab-btn'"
        @click="switchTab('agent')"
      >
        代理商端员工注册数
      </el-button>
      <el-button
        :class="activeTab === 'shop' ? 'tab-btn active' : 'tab-btn'"
        @click="switchTab('shop')"
      >
        美容院端员工注册数
      </el-button>
    </div>

    <!-- 表格区（保持不变） -->
    <el-table
      :data="tableData"
      border
      class="data-table"
      style="width: 100%"
      :header-cell-style="{ background: '#f5f7fa' }"
      :cell-style="{ padding: '8px' }"
    >
      <el-table-column prop="id" label="ID" align="center" />
      <el-table-column prop="name" label="职员姓名" />
      <el-table-column prop="gender" label="性别" align="center" />
      <el-table-column prop="phone" label="手机号" align="center" />
      <el-table-column prop="idCard" label="身份证号" align="center" />
      <el-table-column prop="superior" label="上级" align="center" />
      <el-table-column prop="subordinate" label="下级" align="center" />
    </el-table>

    <!-- 分页区（保持不变） -->
    <div class="pagination-area">
      <div class="total-info">共 10 条 共 10 页</div>
      
      <div class="page-controls">
        <el-button type="text" icon="el-icon-arrow-left" @click="prevPage" :disabled="currentPage === 1" />
        <el-button
          v-for="page in pageList"
          :key="page"
          :class="currentPage === page ? 'page-btn active' : 'page-btn'"
          @click="currentPage = page"
        >
          {{ page }}
        </el-button>
        <el-button type="text" icon="el-icon-arrow-right" @click="nextPage" :disabled="currentPage === totalPages" />
      </div>

      <div class="page-size">
        <span>10条/页</span>
        <el-select v-model="pageSize" @change="handlePageSizeChange" size="mini" class="size-select">
          <el-option label="10条/页" value="10" />
          <el-option label="20条/页" value="20" />
          <el-option label="50条/页" value="50" />
        </el-select>
      </div>

      <div class="jump-area">
        <span>跳至</span>
        <el-input v-model="jumpPage" size="mini" class="jump-input" @keyup.enter="handleJump" />
        <span>页</span>
        <el-button type="primary" size="mini" class="jump-btn" @click="handleJump">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
import { ElMessage } from 'element-plus';

// 标签切换状态（保持逻辑不变）
const activeTab = ref('shop');
const currentPage = ref(1);
const pageSize = ref('10');
const totalPages = ref(10);
const jumpPage = ref('');

// 表格数据（保持不变）
const tableData = ref([
  {
    id: 1,
    name: '张云亮',
    gender: '男',
    phone: '13222786789',
    idCard: '32038472894028',
    superior: '张嘉',
    subordinate: '陈辉'
  },
  {
    id: 2,
    name: '陈辉',
    gender: '男',
    phone: '13222786789',
    idCard: '32038472894028',
    superior: '张云亮',
    subordinate: '刘辉'
  },
  {
    id: 3,
    name: '刘辉',
    gender: '男',
    phone: '13222745889',
    idCard: '32038472894028',
    superior: '陈辉',
    subordinate: '李悦'
  }
]);

const pageList = computed(() => [1, 2, 3, 4]);

// 所有逻辑保持不变
const switchTab = (tab) => {
  activeTab.value = tab;
  currentPage.value = 1;
  ElMessage.info(`已切换至${tab === 'agent' ? '代理商端' : '美容院端'}员工注册数`);
};

const prevPage = () => currentPage.value > 1 && currentPage.value--;
const nextPage = () => currentPage.value < totalPages.value && currentPage.value++;
const handlePageSizeChange = (size) => {
  pageSize.value = size;
  ElMessage.info(`已切换为${size}条/页`);
};
const handleJump = () => {
  const page = Number(jumpPage.value);
  if (!isNaN(page) && page >= 1 && page <= totalPages.value) {
    currentPage.value = page;
  } else {
    ElMessage.warning('请输入有效的页码');
  }
  jumpPage.value = '';
};
const handleReturn = () => ElMessage.info('已返回上一页');
</script>

<style scoped>
/* 仅修改标签相关样式，其他样式保持不变 */
.employee-registration-page {
  padding: 20px;
  font-family: "Microsoft Yahei", sans-serif;
  background: #fff;
  position: relative;
  min-height: 400px;
}

.return-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 0;
  color: #666;
}

/* 核心：标签样式修正 */
.tab-container {
  /* 标签容器底部边框线 */
  border-bottom: 1px solid #d9d9d9;
  padding-bottom: 0;
  margin-bottom: 16px;
  height: 34px; /* 固定高度避免抖动 */
}

.tab-btn {
  /* 基础样式：移除默认按钮样式 */
  border: 1px solid #d9d9d9;
  border-bottom-color: transparent; /* 底部边框透明，让容器边框显示 */
  background: #f9f9f9;
  color: #333;
  padding: 5px 16px;
  margin-right: -1px; /* 重叠边框，避免双线 */
  height: 34px;
  line-height: 22px;
  font-size: 14px;
  border-radius: 0;
}

/* 激活态标签样式（关键修正） */
.tab-btn.active {
  background: #fff;
  color: #000;
  border: 1px solid #d9d9d9;
  border-bottom: 2px solid #fff; /* 白色底部覆盖容器边框 */
  border-top: 2px solid #23c6c8; /* 顶部高亮线 */
  margin-top: -1px; /* 向上微调覆盖容器边框 */
  font-weight: 500;
}

/* 未激活标签hover效果 */
.tab-btn:not(.active):hover {
  background: #f0f0f0;
  color: #333;
}

/* 表格和分页样式保持不变 */
.data-table {
  --el-table-border-color: #dcdcdc;
  --el-table-header-text-color: #333;
  --el-table-body-text-color: #666;
  margin-bottom: 16px;
}

.pagination-area {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: #666;
  flex-wrap: wrap;
}

.total-info {
  margin-right: 8px;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #e5e6eb;
  background: #fff;
  cursor: pointer;
  border-radius: 2px;
}

.page-btn.active {
  background: #23c6c8;
  color: #fff;
  border-color: #23c6c8;
}

.page-size {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-select {
  width: auto;
}

.jump-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jump-input {
  width: 50px;
}

.jump-btn {
  background: #23c6c8;
  border-color: #23c6c8;
  padding: 2px 10px;
}
</style>